app.directive('ngKeyupTimeout', function ngKeyupTimeout($timeout) {
	return function (scope, elem, attrs) {
		elem.stop().bind('keyup', function (event) {
			event.stopPropagation();
			$timeout(function () {
				scope.$apply(attrs.ngKeyupTimeout);
			}, 1000);
		});
	};
});
app.directive('autofillable', ['$timeout', function ($timeout) {
    return {
        scope: true,
        require: 'ngModel',
        link: function (scope, elem, attrs, ctrl) {
            scope.check = function(){
                var val = elem[0].value;
                if(ctrl.$viewValue !== val){
                    ctrl.$setViewValue(val)
                }
                $timeout(scope.check, 300);
            };
            scope.check();
        }
    };
}]);